//
//  BottomBarView.m
//  SHNet
//
//  Created by FranklinPhill on 15/12/18.
//  Copyright © 2015年 Fire. All rights reserved.
//

#import "BottomBarView.h"

@interface BottomBarView () <UITabBarDelegate>

@property (strong, nonatomic) UITabBarItem *indexItem;
@property (strong, nonatomic) UITabBarItem *categoryItem;
@property (strong, nonatomic) UITabBarItem *activityItem;
@property (strong, nonatomic) UITabBarItem *carItem;
@property (strong, nonatomic) UITabBarItem *mineItem;

@end

@implementation BottomBarView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)awakeFromNib {
    [super awakeFromNib];
    self.indexItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:Image(@"tab_index") selectedImage:[Image(@"tab_index_hl") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    _indexItem.tag = 2000;
    [_indexItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBColor(219, 34, 46)} forState:UIControlStateSelected];
    
    self.categoryItem = [[UITabBarItem alloc] initWithTitle:@"分类" image:Image(@"tab_category") selectedImage:[Image(@"tab_category_hl") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    _categoryItem.tag = 2001;
    [_categoryItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBColor(219, 34, 46)} forState:UIControlStateSelected];
    
    self.activityItem = [[UITabBarItem alloc] initWithTitle:@"活动" image:Image(@"tab_activity") selectedImage:[Image(@"tab_activity_hl") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    _activityItem.tag = 2002;
    [_activityItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBColor(219, 34, 46)} forState:UIControlStateSelected];
    
    self.carItem = [[UITabBarItem alloc] initWithTitle:@"购物车" image:Image(@"tab_car") selectedImage:[Image(@"tab_car_hl") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    _carItem.tag = 2003;
    [_carItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBColor(219, 34, 46)} forState:UIControlStateSelected];
    
    self.mineItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:Image(@"tab_mine") selectedImage:[Image(@"tab_mine_hl") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    _mineItem.tag = 2004;
    [_mineItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBColor(219, 34, 46)} forState:UIControlStateSelected];
    
    UIView *bgView = [[UIView alloc] initWithFrame:_tabbar.bounds];
    bgView.backgroundColor = RGBColor(54, 54, 54);
    [_tabbar insertSubview:bgView atIndex:0];
    _tabbar.opaque = YES;
    _tabbar.items = @[_indexItem, _categoryItem, _activityItem, _carItem, _mineItem];
    _tabbar.selectedItem = _indexItem;
}

@end
